package com.sbtr.controller.classify;

import com.sbtr.business.classify.dto.AlgorithmInfoDto;
import com.sbtr.business.classify.entity.AlgorithmInfo;
import com.sbtr.business.classify.service.AlgorithmInfoService;
import com.sbtr.common.PageDto;
import com.sbtr.common.Response;
import com.sbtr.controller.common.CommonController;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 算法信息表 前端控制器
 *
 * @author dgl
 * @since 2023-09-15
 */
@RestController
@RequestMapping("/algorithmInfo")
@Api(tags = "算法信息表")
public class AlgorithmInfoController extends CommonController<AlgorithmInfo,AlgorithmInfoService> {

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<AlgorithmInfo>> pageList(AlgorithmInfoDto algorithmInfoDto){
        return Response.success(u.pageList(algorithmInfoDto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "保存")
    public Response<AlgorithmInfo> save(@RequestBody AlgorithmInfo algorithmInfo){
        algorithmInfo.setId(null);
        if(algorithmInfo.insert()){
            return Response.success(algorithmInfo);
        }else throw new BDException("保存失败");
    }

}

